<!--
 * @Author: licongwei
 * @Date: 2022-03-07 17:22:55
 * @FileDescription: 超市概况
-->
<template>
  <div class="P1">
    <div class="left">
      <div class="box box1">
        <scdjqk />
      </div>
      <div class="box box2">
        <mdslqk @change="handleShopChange" />
      </div>
      <div class="box box3">
        <scjrsjlqk />
      </div>
    </div>
    <div class="center">
      <c-map
        v-if="shopId !== '' && adcode === '650000'"
        :shopId="shopId"
        @change="handleMapClick"
      ></c-map>
      <div v-else-if="adcode !== '650000'" class="bdmap-box">
        <bd-map :adcode="adcode" :shopId="shopId"></bd-map>
        <div class="back-btn" @click="handleMapBack">{{ cityName }}</div>
      </div>
    </div>
    <div class="right">
      <div class="box box1">
        <csdjsjl />
      </div>
      <div class="box box2">
        <gsmdslqk :shopId="shopId"></gsmdslqk>
      </div>
    </div>
  </div>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue'
import cMap from './cpns/map.vue'
import bdMap from './cpns/bdMap.vue'
import scdjqk from './cpns/scdjqk.vue'
import mdslqk from './cpns/mdslqk.vue'
import scjrsjlqk from './cpns/scjrsjlqk.vue'
import csdjsjl from './cpns/csdjsjl.vue'
import gsmdslqk from './cpns/gsmdslqk.vue'
export default defineComponent({
  name: 'P1',
  components: {
    cMap,
    bdMap,
    scdjqk,
    mdslqk,
    scjrsjlqk,
    csdjsjl,
    gsmdslqk
  },
  setup() {
    const adcode = ref('650000')
    const cityName = ref('')
    // 点击全省地图下钻
    const handleMapClick = (code: string, name: string) => {
      adcode.value = code
      cityName.value = name
    }
    // 返回全省
    const handleMapBack = () => {
      adcode.value = '650000'
      cityName.value = ''
    }
    const shopId = ref('')
    // 切换超市类别
    const handleShopChange = (id: string) => {
      shopId.value = id
    }
    return {
      adcode,
      cityName,
      handleMapClick,
      handleMapBack,
      shopId,
      handleShopChange
    }
  }
})
</script>
<style lang="less" scoped>
.P1 {
  display: flex;
  .box {
    overflow: hidden;
  }
  .left {
    flex: 0 0 465px;
    display: flex;
    flex-direction: column;
    .box1 {
      flex: 0 0 400px;
    }
    .box2 {
      flex: 0 0 270px;
      margin: 15px 0;
    }
    .box3 {
      flex: 1;
    }
  }
  .center {
    flex: 1;
    margin: 0 15px;
    .bdmap-box {
      position: relative;
      height: 100%;
      .back-btn {
        position: absolute;
        top: 50px;
        right: 30px;
        z-index: 10;
        width: 44px;
        padding: 30px 0;
        font-size: 26px;
        font-weight: 700;
        color: #ffc924;
        background-color: rgba(0, 71, 157, 0.8);
        border-radius: 10px;
        text-align: center;
        cursor: pointer;
        transition: all 0.2s;
      }
    }
  }
  .right {
    flex: 0 0 465px;
    display: flex;
    flex-direction: column;
    .box1 {
      flex: 0 0 300px;
    }
    .box2 {
      flex: 1;
      margin-top: 15px;
    }
  }
}
</style>
